import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { GuideTipsManager } from "../../manager/GuideTipsManager";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { GuideEquipComp } from "./guideEquipComp/GuideEquipComp";
import { EffectManager } from "../../manager/EffectManager";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
import { LineBox } from "./LineBox";
type int = number;
//class GuideTips
    
    export  class GuideTips /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._rect = new Object /* flash.geom.Rectangle */(70, 10, 10, 4);
            this._bodySprite = new Object /* flash.display.Sprite */();
            this._tips = GlobalClass.getScaleBitmap(ImagesConst.bottomLeft, this._rect);
            this._tips.width = this._tipsWidth;
            this._bodySprite.addChild(this._tips);
            this._txt = new Object /* flash.text.TextField */();
            this._txt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._txt.multiline = true;
            this._txt.wordWrap = true;
            this._txt.selectable = false;
            this._txt.width = 150;
            this._txt.filters = [FilterConst.nameGlowFilter];
            this._bodySprite.addChild(this._txt);
            this.mouseChildren = false;
            this.mouseEnabled = false;
            return;
        }

        /* internal  */updateTipsSize(): void
        {
            this._tips.height = this._hitHeight + 16 + this._txt.textHeight;
            if (this._equipPanel && this._equipPanel.parent) 
            {
                this._equipPanel.y = this._txt.y + this._txt.textHeight + 6;
                this._equipPanel.x = this._txt.x;
                this._tips.height = this._tips.height + (this._equipPanel.height + 6);
            }
            return;
        }

        public updateDir(arg1: int): void
        {
            if (!this._bodySprite.parent) 
            {
                this.addChild(this._bodySprite);
            }
            this._dir = arg1;
            var loc1=arg1;
            switch (loc1) 
            {
                case GuideTipsManager.Dir_BL:
                {
                    this._tips.scaleX = 1;
                    this._tips.scaleY = 1;
                    this._tips.x = 0;
                    this._tips.y = -this._tips.height;
                    this._txt.x = 10;
                    this._txt.y = this._tips.y + 7;
                    break;
                }
                case GuideTipsManager.Dir_BR:
                {
                    this._tips.scaleX = -1;
                    this._tips.scaleY = 1;
                    this._tips.x = 0;
                    this._tips.y = -this._tips.height;
                    this._txt.x = this._tips.x - this._tips.width + 10;
                    this._txt.y = this._tips.y + 7;
                    break;
                }
                case GuideTipsManager.Dir_TL:
                {
                    this._tips.scaleX = 1;
                    this._tips.scaleY = -1;
                    this._tips.x = 0;
                    this._tips.y = this._tips.height;
                    this._txt.x = this._tips.x + 10;
                    this._txt.y = this._hitHeight + 7;
                    break;
                }
                case GuideTipsManager.Dir_TR:
                {
                    this._tips.scaleX = -1;
                    this._tips.scaleY = -1;
                    this._tips.x = 0;
                    this._tips.y = this._tips.height;
                    this._txt.x = this._tips.x - this._tips.width + 10;
                    this._txt.y = this._hitHeight + 7;
                    break;
                }
            }
            this.updateTipsSize();
            return;
        }

        public updateTxt(arg1: string): void
        {
            this._txt.htmlText = HTMLUtil.addColor(arg1, "#ffffff");
            this.updateTipsSize();
            return;
        }

        public updateEquipComp(arg1: int): void
        {
            if (!this._equipPanel) 
            {
                this._equipPanel = new GuideEquipComp(this._tipsWidth - 20);
            }
            if (!this._equipPanel.parent) 
            {
                this._bodySprite.addChild(this._equipPanel);
            }
            this._equipPanel.updateData(arg1);
            this.updateTipsSize();
            return;
        }

        public updateRect(arg1: int, arg2: int): void
        {
            if (arg1 <= 0 || arg2 <= 0) 
            {
                return;
            }
            this._lineBox = EffectManager.getLineBox(arg1 + 4, arg2 + 4, [16711680, 16776960]);
            if (this._lineBox.parent != this) 
            {
                this.addChild(this._lineBox);
            }
            this._lineBox.x = (-arg1) / 2 - 2;
            this._lineBox.y = -arg2 - 2;
            return;
        }

        public updateCallBack(arg1: Function): void
        {
            this._callBack = arg1;
            if (arg1 == null) 
            {
                this.mouseChildren = false;
                this.mouseEnabled = false;
                this._bodySprite.removeEventListener(flash.events.MouseEvent.CLICK, this.onMouseClick);
            }
            else 
            {
                this.mouseEnabled = false;
                this.mouseChildren = true;
                this._bodySprite.mouseEnabled = true;
                this._bodySprite.addEventListener(flash.events.MouseEvent.CLICK, this.onMouseClick);
            }
            return;
        }

        public get txt(): Object /* flash.text.TextField */
        {
            return this._txt;
        }

        /* internal  */onMouseClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._callBack != null) 
            {
                this._callBack();
            }
            return;
        }

        public dispose(): void
        {
            this.baseX = 0;
            this.baseY = 0;
            this.baseLayer = null;
            this.mouseChildren = false;
            this.mouseEnabled = false;
            this._bodySprite.removeEventListener(flash.events.MouseEvent.CLICK, this.onMouseClick);
            EffectManager.glowFilterUnReg(this);
            EffectManager.disposeLineBox(this._lineBox);
            this._bodySprite.filters = null;
            if (this._bodySprite.parent) 
            {
                this.removeChild(this._bodySprite);
            }
            this._callBack = null;
            if (this._equipPanel) 
            {
                if (this._equipPanel.parent) 
                {
                    this._equipPanel.parent.removeChild(this._equipPanel);
                }
                this._equipPanel.dispose();
            }
            return;
        }

        /* internal */ /* const */_hitHeight: int=25;

        /* internal */ /* const */_tipsWidth: int=170;

        /* internal */ /* var */_tips: ScaleBitmap;

        /* internal */ /* var */_txt: Object /* flash.text.TextField */;

        /* internal */ /* var */_equipPanel: GuideEquipComp;

        /* internal */ /* var */_dir: int;

        /* internal */ /* var */_bodySprite: Object /* flash.display.Sprite */;

        /* internal */ /* var */_lineBox: LineBox;

        /* internal */ /* var */_callBack: Function;

        public /* var */baseX: number=0;

        public /* var */baseY: number=0;

        /* internal */ /* var */_rect: Object /* flash.geom.Rectangle */;

        public /* var */baseLayer: Object /* flash.display.DisplayObject */;
    }
